package com.demo.controller;

import com.demo.dto.OrderDTO;
import com.demo.entity.Carousel;
import com.demo.entity.Order;
import com.demo.model.JsonMessage;
import com.demo.security.AuthUserDetail;
import com.demo.service.CarouselService;
import com.demo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;
import java.util.List;

@Controller
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService service;

    @PostMapping("findAllOrders")
    @ResponseBody
    public JsonMessage findAllOrders() {
        JsonMessage message = new JsonMessage();
        List<OrderDTO> list = service.findAllOrders();
        message.setData(list);
        return message;
    }

    @PostMapping("findOrdersById")
    @ResponseBody
    public JsonMessage findOrdersById(BigDecimal orderId) {
        JsonMessage message = new JsonMessage();
        List<Order> list = service.findOrdersById(orderId);
        message.setData(list);
        return message;
    }

}
